{% extends "base.html" %}

{% block title %}订单详情{% endblock %}

{% block content %}
<div class="container my-5">
    <div class="card">
        <div class="card-header bg-primary text-white">
            <h3>订单详情</h3>
        </div>
        <div class="card-body">
            <div class="row mb-4">
                <div class="col-md-6">
                    <h5>订单信息</h5>
                    <p><strong>订单号：</strong> {{ order.id }}</p>
                    <p><strong>下单时间：</strong> {{ order.created_at.strftime('%Y-%m-%d %H:%M:%S') if order.created_at else '未知' }}</p>
                    <p><strong>支付方式：</strong> {{ order.payment_method }}</p>
                    <p><strong>订单状态：</strong> 
                        {% if order.status == 'paid' %}
                        <span class="badge bg-success">已支付</span>
                        {% elif order.status == 'pending' %}
                        <span class="badge bg-warning">待支付</span>
                        {% elif order.status == 'canceled' %}
                        <span class="badge bg-secondary">已取消</span>
                        {% endif %}
                    </p>
                </div>
                <div class="col-md-6">
                    <h5>支付信息</h5>
                    <p><strong>总金额：</strong> {{ order.total_price }}元</p>
                    <p><strong>交易号：</strong> {{ order.transaction_id or '无' }}</p>
                </div>
            </div>

            <hr>

            <h5>电影信息</h5>
            <div class="row">
                <div class="col-md-4">
                    <p><strong>电影名称：</strong> {{ order.show.movie.title }}</p>
                    <p><strong>导演：</strong> {{ order.show.movie.director }}</p>
                    <p><strong>主演：</strong> {{ order.show.movie.actors }}</p>
                </div>
                <div class="col-md-4">
                    <p><strong>影院：</strong> {{ order.show.cinema.name }}</p>
                    <p><strong>影厅：</strong> {{ order.show.hall }}</p>
                    <p><strong>座位：</strong> {{ order.seats }}</p>
                </div>
                <div class="col-md-4">
                    <p><strong>放映时间：</strong> {{ order.show.start_time.strftime('%Y-%m-%d %H:%M') }}</p>
                    <p><strong>结束时间：</strong> {{ order.show.end_time.strftime('%Y-%m-%d %H:%M') }}</p>
                    <p><strong>时长：</strong> {{ order.show.movie.duration }}分钟</p>
                </div>
            </div>

            <div class="mt-4">
                {% if order.status == 'paid' %}
                <form action="{{ url_for('cancel_order', order_id=order.id) }}" method="post">
                    <button type="submit" class="btn btn-danger">取消订单</button>
                </form>
                {% endif %}
                <a href="{{ url_for('profile') }}" class="btn btn-secondary">返回个人中心</a>
            </div>
        </div>
    </div>
</div>
{% endblock %}